﻿using System;
using System.Collections.Generic;

using AzureContrib.WindowsAzure.ServiceRuntime;

namespace AzureContrib.WindowsAzure.Tests.Mocks
{
	/// <summary>
	/// A null <see cref="IRoleEnvironment"/>
	/// </summary>
	public class NullRoleEnvironment : IRoleEnvironment
	{
		/// <summary>
		/// A null <see cref="IRoleEnvironment"/>
		/// </summary>
		public event EventHandler<RoleEnvironmentChangedEventArgs> Changed;

		/// <summary>
		/// A mock <see cref="IRoleEnvironment"/>
		/// </summary>
		public void OnChanged(RoleEnvironmentChangedEventArgs e)
		{
			EventHandler<RoleEnvironmentChangedEventArgs> handler = Changed;
			if (handler != null)
			{
				handler(this, e);
			}
		}

		/// <summary>
		/// A null <see cref="IRoleEnvironment"/>
		/// </summary>
		public event EventHandler<RoleEnvironmentChangingEventArgs> Changing;

		/// <summary>
		/// A mock <see cref="IRoleEnvironment"/>
		/// </summary>
		public void OnChanging(RoleEnvironmentChangingEventArgs e)
		{
			EventHandler<RoleEnvironmentChangingEventArgs> handler = Changing;
			if (handler != null)
			{
				handler(this, e);
			}
		}

		/// <summary>
		/// A null <see cref="IRoleEnvironment"/>
		/// </summary>
		public IRoleInstance CurrentRoleInstance
		{
			get
			{
				return null;
			}
		}

		/// <summary>
		/// A null <see cref="IRoleEnvironment"/>
		/// </summary>
		public string DeploymentId
		{
			get
			{
				return null;
			}
		}

		/// <summary>
		/// A null <see cref="IRoleEnvironment"/>
		/// </summary>
		public bool IsAvailable
		{
			get
			{
				return true;
			}
		}

		/// <summary>
		/// A null <see cref="IRoleEnvironment"/>
		/// </summary>
		public IDictionary<string, IRole> Roles
		{
			get
			{
				return new Dictionary<string, IRole>();
			}
		}

		/// <summary>
		/// A null <see cref="IRoleEnvironment"/>
		/// </summary>
		public string GetConfigurationSettingValue(string roleSettingName)
		{
			return null;
		}

		/// <summary>
		/// A null <see cref="IRoleEnvironment"/>
		/// </summary>
		public ILocalResource GetLocalResource(string localResourceName)
		{
			return null;
		}

		/// <summary>
		/// A null <see cref="IRoleEnvironment"/>
		/// </summary>
		public void RequestRecycle()
		{
		}

		/// <summary>
		/// A null <see cref="IRoleEnvironment"/>
		/// </summary>
		public bool TryGetConfigurationSettingValue(string configurationSettingName, out string settingValue)
		{
			throw new NotImplementedException();
		}
	}
}